package com.tbit.main.service.impl;

import com.tbit.main.constant.DaoParamConstant;
import com.tbit.main.dao.log.MainFinishOrderLogDao;
import com.tbit.main.pojo.MainFinishOrderLog;
import com.tbit.main.service.MainFinishOrderLogService;
import com.tbit.main.util.DateTimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 运维结束订单记录
 *
 * @author Leon
 * 2019年11月22日 下午11:08:13
 */
@Service("mainFinishOrderLogService")
public class MainFinishOrderLogServiceImpl implements MainFinishOrderLogService {
    @Autowired
    private MainFinishOrderLogDao mainFinishOrderLogDao;

    @Override
    public void insert(MainFinishOrderLog mainFinishOrderLog) {
        mainFinishOrderLog.setFinishTime(DateTimeUtil.getNowTime());
        mainFinishOrderLogDao.insert(mainFinishOrderLog);
    }

    @Override
    public List<MainFinishOrderLog> query(Integer accountId, String userCode, String startTime, String endTime) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(DaoParamConstant.accountId, accountId);
        params.put("userCode", userCode);
        params.put(DaoParamConstant.startTime, startTime);
        params.put(DaoParamConstant.endTime, endTime);

        return mainFinishOrderLogDao.query(params);
    }

    @Override
    public List<MainFinishOrderLog> queryAll(Integer accountId, String userCode, String startTime, String endTime, Integer mainUserId) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(DaoParamConstant.accountId, accountId);
        params.put("userCode", userCode);
        params.put("mainUserId", mainUserId);
        params.put(DaoParamConstant.startTime, startTime);
        params.put(DaoParamConstant.endTime, endTime);
        return mainFinishOrderLogDao.queryAll(params);
    }

}
